import type { AppRouteModule } from '@/router/types'
import { RoleEnum } from '@/enums/roleEnum'

const permission: AppRouteModule = {
  path: '/permission',
  name: 'Permission',
  meta: {
    type: 'menu',
    title: '权限管理',
    icon: 'key'
  },
  component: () => import(/* webpackChunkName: "empty" */ '@/layout/cnps/empty/empty.vue'),
  children: [
    {
      path: 'front',
      name: 'PermissionFrontDemo',
      redirect: '/permission/front/page',
      meta: {
        title: '基于前端权限'
      },
      component: () =>
        import(/* webpackChunkName: "PermissionFrontDemo" */ '@/layout/cnps/empty/empty.vue'),
      children: [
        {
          path: 'page',
          name: 'FrontPageAuth',
          meta: {
            title: '页面权限'
          },
          component: () =>
            import(
              /* webpackChunkName: "FrontPageAuth" */ '@/views/pages/permission/front/index.vue'
            )
        },
        {
          path: 'btn',
          name: 'FrontBtnAuth',
          meta: {
            title: '按钮权限'
          },
          component: () =>
            import(/* webpackChunkName: "FrontBtnAuth" */ '@/views/pages/permission/front/Btn.vue')
        },
        {
          path: 'auth-pageA',
          name: 'FrontAuthPageA',
          meta: {
            title: '权限测试页A',
            roles: [RoleEnum.SUPER]
          },
          component: () =>
            import(
              /* webpackChunkName: "FrontAuthPageA" */ '@/views/pages/permission/front/AuthPageA.vue'
            )
        },
        {
          path: 'auth-pageB',
          name: 'FrontAuthPageB',
          meta: {
            title: '权限测试页B',
            roles: [RoleEnum.TEST]
          },
          component: () =>
            import(
              /* webpackChunkName: "FrontAuthPageB" */ '@/views/pages/permission/front/AuthPageB.vue'
            )
        }
      ]
    },
    {
      path: 'back',
      name: 'PermissionBackDemo',
      redirect: '/permission/back/page',
      meta: {
        title: '基于后台权限'
      },
      component: () =>
        import(/* webpackChunkName: "PermissionBackDemo" */ '@/layout/cnps/empty/empty.vue'),
      children: [
        {
          path: 'page',
          name: 'BackAuthPage',
          meta: {
            title: '页面权限'
          },
          component: () =>
            import(/* webpackChunkName: "BackAuthPage" */ '@/views/pages/permission/back/index.vue')
        },
        {
          path: 'btn',
          name: 'BackAuthBtn',
          meta: {
            title: '按钮权限'
          },
          component: () =>
            import(/* webpackChunkName: "BackAuthBtn" */ '@/views/pages/permission/back/Btn.vue')
        }
      ]
    }
  ]
}

export default permission
